Owl(window).onLoad(function(){
	var $ = Owl;
	$(window)
		.addEvent('resize scroll',function( event ){
		
			var side = $("#side"),width;
			if( side.size() == 0 ) return;
			if( side.k(0).top === undefined || event.type == 'resize'){
				side.k(0).top = side.top();
				side.k(0).left = side.left();
			}	

			if( document.body.scrollTop > side.k(0).top ){
				if( side.css('position') != 'fixed' || event.type == 'resize' ){
					side.css({
						position:'fixed',
						top: '0px',
						zIndex: 10,
						width: side.width()+'px'
					});
				}	
				
				side.css({
					left: ( side.k(0).left - document.body.scrollLeft )+'px'
				});				
			}else{
				if( side.css('position') == 'fixed' ){
					side.css({
						position:'static'					
					});			
				}	
			}
			//return;
			var menu = $("#content .x-list-title");
			if( menu.k(0).top === undefined || event.type == 'resize' ){
				menu.k(0).top = menu.top();
				menu.k(0).left = menu.left();
			}	
			
			if( document.body.scrollTop > menu.k(0).top ){
				if( menu.css('position') != 'fixed' || event.type == 'resize' ){
					menu.css('position:static');
					
					width = menu.width() 
						- parseInt(menu.css('padding-left')||0)
						- parseInt(menu.css('padding-right')||0)
						- parseInt(menu.css('border-left-width')||0)
						- parseInt(menu.css('border-right-width')||0);
						
					menu.css({
						position: 'fixed',
						top: '0px',
						width: width+'px',
						zIndex:10,
						boxShadow:'0px 1px 1px #ccc',
						WebkitBoxShadow:'0px 1px 1px #ccc',
						MozShadow:'0px 1px 1px #ccc',
						OShadow:'0px 1px 1px #ccc'
					});
				}
				
				menu.css({
					left: ( menu.k(0).left - document.body.scrollLeft ) +'px'
				});				
			}else{
				if( menu.css('position') == 'fixed' ){
					menu.css({
						position:'static',
						width:'auto',
						boxShadow:'0px 1px 0px #ccc',
						WebkitBoxShadow:'0px 0px 0px #ccc',
						MozShadow:'0px 0px 0px #ccc',
						OShadow:'0px 0px 0px #ccc'
					});			
				}	
			}		
		});
});